package com.ruoyi.web.controller.qif;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.qif.domain.QifStatistics;
import com.ruoyi.qif.service.IQifStatisticsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 锜风公寓-营业统计Controller
 * 
 * @author David
 * @date 2025-11-03
 */
@Controller
@RequestMapping("/qif/statistics")
public class QifStatisticsController extends BaseController
{
    private String prefix = "qif/statistics";

    @Autowired
    private IQifStatisticsService qifStatisticsService;

    @RequiresPermissions("qif:statistics:view")
    @GetMapping()
    public String statistics()
    {
        return prefix + "/statistics";
    }

    /**
     * 查询锜风公寓-营业统计列表
     */
    @RequiresPermissions("qif:statistics:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(QifStatistics qifStatistics)
    {
        startPage();
        List<QifStatistics> list = qifStatisticsService.selectQifStatisticsList(qifStatistics);
        return getDataTable(list);
    }

    /**
     * 导出锜风公寓-营业统计列表
     */
    @RequiresPermissions("qif:statistics:export")
    @Log(title = "锜风公寓-营业统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(QifStatistics qifStatistics)
    {
        List<QifStatistics> list = qifStatisticsService.selectQifStatisticsList(qifStatistics);
        ExcelUtil<QifStatistics> util = new ExcelUtil<QifStatistics>(QifStatistics.class);
        return util.exportExcel(list, "锜风公寓-营业统计数据");
    }

    /**
     * 新增锜风公寓-营业统计
     */
    @RequiresPermissions("qif:statistics:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存锜风公寓-营业统计
     */
    @RequiresPermissions("qif:statistics:add")
    @Log(title = "锜风公寓-营业统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(QifStatistics qifStatistics)
    {
        return toAjax(qifStatisticsService.insertQifStatistics(qifStatistics));
    }

    /**
     * 修改锜风公寓-营业统计
     */
    @RequiresPermissions("qif:statistics:edit")
    @GetMapping("/edit/{statisticsId}")
    public String edit(@PathVariable("statisticsId") Long statisticsId, ModelMap mmap)
    {
        QifStatistics qifStatistics = qifStatisticsService.selectQifStatisticsByStatisticsId(statisticsId);
        mmap.put("qifStatistics", qifStatistics);
        return prefix + "/edit";
    }

    /**
     * 修改保存锜风公寓-营业统计
     */
    @RequiresPermissions("qif:statistics:edit")
    @Log(title = "锜风公寓-营业统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(QifStatistics qifStatistics)
    {
        return toAjax(qifStatisticsService.updateQifStatistics(qifStatistics));
    }

    /**
     * 删除锜风公寓-营业统计
     */
    @RequiresPermissions("qif:statistics:remove")
    @Log(title = "锜风公寓-营业统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(qifStatisticsService.deleteQifStatisticsByStatisticsIds(ids));
    }
}
